<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>深入解析Guava中的布隆过滤器</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9fafb;
        }
        .serif {
            font-family: 'Noto Serif SC', serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            overflow-x: auto;
        }
        .code-block pre {
            margin: 0;
            padding: 1.5rem;
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .section-divider {
            height: 1px;
            background: linear-gradient(90deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0) 100%);
            margin: 3rem 0;
        }
        .floating-animation {
            animation: float 6s ease-in-out infinite;
        }
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-15px); }
            100% { transform: translateY(0px); }
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 md:py-32 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="serif text-4xl md:text-5xl font-bold mb-6 leading-tight">
                        揭秘Guava中的<br>布隆过滤器魔法
                    </h1>
                    <p class="text-xl mb-8 opacity-90">
                        用极小的内存换取高效判断，解决缓存穿透难题
                    </p>
                    <div class="flex items-center space-x-4">
                        <div class="flex items-center bg-white bg-opacity-20 px-4 py-2 rounded-full">
                            <i class="fas fa-memory mr-2"></i>
                            <span>极低内存占用</span>
                        </div>
                        <div class="flex items-center bg-white bg-opacity-20 px-4 py-2 rounded-full">
                            <i class="fas fa-bolt mr-2"></i>
                            <span>O(k)查询效率</span>
                        </div>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute -top-10 -left-10 w-32 h-32 bg-purple-400 rounded-full opacity-20"></div>
                        <div class="absolute -bottom-10 -right-10 w-40 h-40 bg-blue-400 rounded-full opacity-20"></div>
                        <div class="relative bg-white p-6 rounded-xl shadow-xl text-gray-800 floating-animation">
                            <div class="flex justify-between items-center mb-4">
                                <h3 class="font-bold text-lg">BloomFilter结构</h3>
                                <div class="flex space-x-2">
                                    <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                    <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                    <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                                </div>
                            </div>
                            <div class="code-block text-sm">
                                <pre>// 核心结构
public class BloomFilter {
    private BitArray bits;
    private Funnel funnel;
    private Strategy strategy;
    private int numHashFunctions;
}</pre>
                            </div>
                            <div class="mt-4 flex space-x-2">
                                <span class="px-2 py-1 bg-blue-100 text-blue-800 text-xs rounded">位数组</span>
                                <span class="px-2 py-1 bg-green-100 text-green-800 text-xs rounded">哈希策略</span>
                                <span class="px-2 py-1 bg-purple-100 text-purple-800 text-xs rounded">误判率</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 py-12">
        <!-- Intro Section -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-8">
                    <div class="flex items-center mb-6">
                        <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-lightbulb text-blue-600 text-xl"></i>
                        </div>
                        <h2 class="serif text-3xl font-bold">布隆过滤器的神奇之处</h2>
                    </div>
                    <div class="prose max-w-none">
                        <blockquote class="border-l-4 border-blue-500 pl-4 italic text-gray-600 my-6">
                            "就这么个小玩意儿，能挡住那么多无效请求？"没错，布隆过滤器就是这么神奇，用极小的内存换取高效的判断。
                        </blockquote>
                        <p class="mb-4">
                            布隆过滤器是一种空间效率很高的概率型数据结构，用于判断一个元素是否在集合中。它的特点是：
                        </p>
                        <div class="grid md:grid-cols-2 gap-6 my-6">
                            <div class="bg-blue-50 p-6 rounded-lg">
                                <div class="flex items-center mb-3">
                                    <div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-3">
                                        <i class="fas fa-check text-blue-600"></i>
                                    </div>
                                    <h3 class="font-bold text-lg">优点</h3>
                                </div>
                                <ul class="space-y-2">
                                    <li class="flex items-start">
                                        <i class="fas fa-angle-right text-blue-500 mt-1 mr-2"></i>
                                        <span>查询高效：O(k)时间复杂度</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-angle-right text-blue-500 mt-1 mr-2"></i>
                                        <span>空间节省：比传统集合节省大量空间</span>
                                    </li>
                                </ul>
                            </div>
                            <div class="bg-orange-50 p-6 rounded-lg">
                                <div class="flex items-center mb-3">
                                    <div class="w-8 h-8 bg-orange-100 rounded-full flex items-center justify-center mr-3">
                                        <i class="fas fa-exclamation text-orange-600"></i>
                                    </div>
                                    <h3 class="font-bold text-lg">局限</h3>
                                </div>
                                <ul class="space-y-2">
                                    <li class="flex items-start">
                                        <i class="fas fa-angle-right text-orange-500 mt-1 mr-2"></i>
                                        <span>有误判：可能误判不在集合的元素</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-angle-right text-orange-500 mt-1 mr-2"></i>
                                        <span>不支持删除：一般实现不支持删除元素</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Section 1 -->
        <section id="section1" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-blue-600 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">01</div>
                <h2 class="serif text-3xl font-bold">数据结构设计与哈希算法选择</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-sitemap text-blue-500 mr-2"></i>
                            Guava的BloomFilter核心结构
                        </h3>
                        <div class="code-block text-sm mb-4">
                            <pre>public final class BloomFilter&lt;T&gt; {
    private final BitArray bits;       // 位数组
    private final Funnel funnel;       // 输入处理
    private final Strategy strategy;   // 策略接口
    private final int numHashFunctions;// 哈希函数个数
    
    public boolean mightContain(T obj) {
        return strategy.mightContain(obj, funnel, 
               numHashFunctions, bits);
    }
}</pre>
                        </div>
                        <p class="text-gray-600">
                            Guava的实现非常优雅，使用位数组(BitArray)存储数据，通过策略模式实现核心逻辑。
                        </p>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-fingerprint text-purple-500 mr-2"></i>
                            巧妙哈希算法设计
                        </h3>
                        <div class="code-block text-sm mb-4">
                            <pre>// MurmurHash3双重哈希技巧
long hash64 = Hashing.murmur3_128()
       .hashObject(object, funnel).asLong();
long hash1 = hash64;
long hash2 = hash64 >>> 32;

// 生成第i个哈希位置
long combinedHash = hash1 + (i * hash2);</pre>
                        </div>
                        <p class="text-gray-600">
                            只需计算一次128位哈希，然后通过数学组合生成多个哈希值，比计算多个独立哈希高效得多。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Section 2 -->
        <section id="section2" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-purple-600 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">02</div>
                <h2 class="serif text-3xl font-bold">误判率控制机制分析</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover">
                <div class="p-8">
                    <h3 class="font-bold text-xl mb-4">误判率理论公式</h3>
                    <div class="flex flex-col md:flex-row items-center">
                        <div class="md:w-1/2 mb-6 md:mb-0">
                            <div class="bg-gray-50 p-6 rounded-lg">
                                <p class="text-gray-600 mb-4">
                                    布隆过滤器的误判率由三个因素决定：
                                </p>
                                <ul class="space-y-2 mb-4">
                                    <li>位数组大小(m)</li>
                                    <li>哈希函数个数(k)</li>
                                    <li>插入元素数量(n)</li>
                                </ul>
                                <p class="text-gray-600">
                                    理论关系：
                                </p>
                            </div>
                        </div>
                        <div class="md:w-1/2 bg-gray-800 text-white p-6 rounded-lg">
                            <div class="text-center text-2xl font-mono">
                                p ≈ (1 - e<sup>-kn/m</sup>)<sup>k</sup>
                            </div>
                            <p class="text-gray-300 mt-4 text-sm">
                                其中p是误判率，e是自然对数的底数
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-calculator text-green-500 mr-2"></i>
                            最优参数计算
                        </h3>
                        <div class="code-block text-sm mb-4">
                            <pre>// 计算最优位数组大小
static int optimalNumOfBits(long n, double p) {
    return (int) Math.ceil(-n * Math.log(p) 
           / (Math.log(2) * Math.log(2)));
}

// 计算最优哈希函数个数
static int optimalNumOfHashFunctions(long n, long m) {
    return Math.max(1, (int) Math.round(
           (double) m / n * Math.log(2)));
}</pre>
                        </div>
                        <p class="text-gray-600">
                            Guava自动计算最优参数，确保在给定误判率和元素数量下，使用最少的空间。
                        </p>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-chart-bar text-orange-500 mr-2"></i>
                            实际误判率测试
                        </h3>
                        <div class="mb-4">
                            <div class="flex justify-between text-sm mb-1">
                                <span>期望误判率: 1%</span>
                                <span>实际误判率: 0.92%</span>
                            </div>
                            <div class="w-full bg-gray-200 rounded-full h-2.5">
                                <div class="bg-green-600 h-2.5 rounded-full" style="width: 92%"></div>
                            </div>
                        </div>
                        <p class="text-gray-600">
                            实测表明Guava的BloomFilter实际误判率与理论值非常接近，通常会稍微低于设定值。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Section 3 -->
        <section id="section3" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-green-600 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">03</div>
                <h2 class="serif text-3xl font-bold">内存优化与性能调优实现</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover">
                <div class="p-8">
                    <h3 class="font-bold text-xl mb-6">内存占用对比</h3>
                    <div class="grid md:grid-cols-2 gap-6">
                        <div>
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-filter text-blue-500 mr-2"></i>
                                BloomFilter (1000万元素, 1%误判率)
                            </h4>
                            <div class="bg-blue-50 p-4 rounded-lg">
                                <div class="text-3xl font-bold text-blue-600 mb-2">≈11.5MB</div>
                                <p class="text-sm text-gray-600">使用BitArray存储，每个元素仅需约1.15字节</p>
                            </div>
                        </div>
                        <div>
                            <h4 class="font-semibold mb-3 flex items-center">
                                <i class="fas fa-database text-purple-500 mr-2"></i>
                                HashSet (1000万元素)
                            </h4>
                            <div class="bg-purple-50 p-4 rounded-lg">
                                <div class="text-3xl font-bold text-purple-600 mb-2">>1GB</div>
                                <p class="text-sm text-gray-600">仅String对象就需要至少400MB</p>
                            </div>
                        </div>
                    </div>
                    <div class="mt-6 bg-yellow-50 p-4 rounded-lg border-l-4 border-yellow-400">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-lightbulb text-yellow-500"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-sm text-yellow-700">
                                    内存节省了近百倍！这使得BloomFilter成为处理海量数据集的理想选择。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-tachometer-alt text-red-500 mr-2"></i>
                            性能优化技巧
                        </h3>
                        <div class="space-y-4">
                            <div class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 bg-red-100 rounded-full flex items-center justify-center">
                                        <i class="fas fa-check text-red-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="text-gray-700">使用位运算代替取模运算</p>
                                    <p class="text-sm text-gray-500 mt-1"><code>hash & (numBits - 1)</code> 代替 <code>hash % numBits</code></p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 bg-red-100 rounded-full flex items-center justify-center">
                                        <i class="fas fa-check text-red-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="text-gray-700">双重哈希技术</p>
                                    <p class="text-sm text-gray-500 mt-1">仅需计算一次哈希，生成多个位置</p>
                                </div>
                            </div>
                            <div class="flex items-start">
                                <div class="flex-shrink-0 mt-1">
                                    <div class="w-6 h-6 bg-red-100 rounded-full flex items-center justify-center">
                                        <i class="fas fa-check text-red-500 text-xs"></i>
                                    </div>
                                </div>
                                <div class="ml-3">
                                    <p class="text-gray-700">缓存友好的数据访问</p>
                                    <p class="text-sm text-gray-500 mt-1">减少内存随机访问，提高缓存命中率</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-file-export text-indigo-500 mr-2"></i>
                            序列化设计
                        </h3>
                        <div class="code-block text-sm mb-4">
                            <pre>// 序列化
void writeTo(ObjectOutputStream out) {
    out.writeInt(data.length);
    for (long value : data) {
        out.writeLong(value);
    }
}

// 反序列化
static BitArray readFrom(ObjectInputStream in) {
    int dataLength = in.readInt();
    long[] data = new long[dataLength];
    for (int i = 0; i < dataLength; i++) {
        data[i] = in.readLong();
    }
    return new BitArray(data);
}</pre>
                        </div>
                        <p class="text-gray-600">
                            高效的序列化设计支持持久化和分布式传输，使用long数组存储位数据，序列化体积小。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Section 4 -->
        <section id="section4" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-indigo-600 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">04</div>
                <h2 class="serif text-3xl font-bold">缓存穿透防护实战</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 card-hover">
                <div class="p-8">
                    <h3 class="font-bold text-xl mb-6 flex items-center">
                        <i class="fas fa-shield-alt text-indigo-500 mr-2"></i>
                        缓存穿透问题解决方案
                    </h3>
                    <div class="prose max-w-none">
                        <p class="mb-4">
                            缓存穿透指的是查询一个不存在的数据，缓存没有，查询打到数据库，数据库也没有。如果有人恶意构造大量不存在的ID进行查询，可能导致数据库崩溃。
                        </p>
                        
                        <div class="grid md:grid-cols-2 gap-6 my-6">
                            <div>
                                <h4 class="font-semibold mb-3 text-lg">传统方案的问题</h4>
                                <ul class="space-y-2 text-gray-600">
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>缓存空值浪费空间</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>缓存雪崩风险</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-times-circle text-red-500 mt-1 mr-2"></i>
                                        <span>无法应对随机攻击</span>
                                    </li>
                                </ul>
                            </div>
                            <div>
                                <h4 class="font-semibold mb-3 text-lg">BloomFilter方案</h4>
                                <ul class="space-y-2 text-gray-600">
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>极低内存占用</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>O(k)查询效率</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                                        <span>有效拦截无效请求</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                <div class="p-8">
                    <h3 class="font-bold text-xl mb-6 flex items-center">
                        <i class="fas fa-code text-blue-500 mr-2"></i>
                        电商系统实战代码
                    </h3>
                    <div class="code-block text-sm mb-6">
                        <pre>public class ProductService {
    private Cache&lt;Long, Product&gt; cache;
    private BloomFilter&lt;Long&gt; bloomFilter;
    
    public ProductService() {
        // 初始化布隆过滤器 (100万商品,1%误判率)
        this.bloomFilter = BloomFilter.create(
            Funnels.longFunnel(),
            1_000_000, 
            0.01);
        
        // 预热布隆过滤器
        List&lt;Long&gt; allIds = repository.getAllProductIds();
        for (Long id : allIds) {
            bloomFilter.put(id);
        }
    }
    
    public Product getProduct(Long id) {
        // 先判断ID是否可能存在
        if (!bloomFilter.mightContain(id)) {
            return null;  // ID一定不存在
        }
        
        // 正常缓存查询流程...
    }
}</pre>
                    </div>
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold mb-2 flex items-center">
                            <i class="fas fa-chart-line text-blue-500 mr-2"></i>
                            实际效果
                        </h4>
                        <p class="text-gray-600">
                            在生产环境中，这个方案成功将缓存穿透攻击的数据库压力降低了99%以上，同时仅使用约1.2MB内存存储100万商品ID的布隆过滤器。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Section 5 -->
        <section id="section5" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-orange-600 rounded-full flex items-center justify-center text-white font-bold text-xl mr-4">05</div>
                <h2 class="serif text-3xl font-bold">局限性与替代方案</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-ban text-orange-500 mr-2"></i>
                            不支持删除的解决方案
                        </h3>
                        <div class="space-y-4">
                            <div class="p-4 bg-gray-50 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-calculator text-blue-500 mr-2"></i>
                                    计数布隆过滤器
                                </h4>
                                <p class="text-sm text-gray-600">
                                    使用计数器数组代替位数组，支持增减操作但内存占用增加。
                                </p>
                            </div>
                            <div class="p-4 bg-gray-50 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-sync-alt text-green-500 mr-2"></i>
                                    定期重建策略
                                </h4>
                                <p class="text-sm text-gray-600">
                                    记录删除操作，定期重建过滤器，适合删除不频繁场景。
                                </p>
                            </div>
                            <div class="p-4 bg-gray-50 rounded-lg">
                                <h4 class="font-semibold mb-2 flex items-center">
                                    <i class="fas fa-kiwi-bird text-purple-500 mr-2"></i>
                                    Cuckoo Filter
                                </h4>
                                <p class="text-sm text-gray-600">
                                    替代数据结构，支持删除操作，但实现更复杂。
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
                    <div class="p-6">
                        <h3 class="font-bold text-xl mb-4 flex items-center">
                            <i class="fas fa-check-circle text-green-500 mr-2"></i>
                            适用场景与经验
                        </h3>
                        <div class="grid gap-4">
                            <div>
                                <h4 class="font-semibold mb-2">适用场景</h4>
                                <ul class="text-sm text-gray-600 space-y-2">
                                    <li class="flex items-start">
                                        <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                        <span>缓存穿透防护</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                        <span>垃圾邮件过滤</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                        <span>URL去重</span>
                                    </li>
                                </ul>
                            </div>
                            <div>
                                <h4 class="font-semibold mb-2">实战经验</h4>
                                <ul class="text-sm text-gray-600 space-y-2">
                                    <li class="flex items-start">
                                        <i class="fas fa-lightbulb text-blue-500 mt-1 mr-2"></i>
                                        <span>误判率通常设为1%(0.01)</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-lightbulb text-blue-500 mt-1 mr-2"></i>
                                        <span>定期抽样测试实际误判率</span>
                                    </li>
                                    <li class="flex items-start">
                                        <i class="fas fa-lightbulb text-blue-500 mt-1 mr-2"></i>
                                        <span>增量更新与全量更新结合</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Conclusion -->
        <section class="bg-white rounded-xl shadow-md overflow-hidden p-8 mb-20 card-hover">
            <div class="text-center">
                <h2 class="serif text-3xl font-bold mb-6">布隆过滤器：空间与效率的完美平衡</h2>
                <p class="text-xl text-gray-600 max-w-3xl mx-auto mb-8">
                    Guava的BloomFilter实现展示了如何在极小的内存空间中实现高效的元素存在性判断，通过巧妙的数据结构设计和算法优化，为解决缓存穿透等实际问题提供了优雅的解决方案。
                </p>
                <div class="flex justify-center space-x-4">
                    <div class="px-4 py-2 bg-blue-100 text-blue-800 rounded-full inline-flex items-center">
                        <i class="fas fa-memory mr-2"></i>
                        <span>极小内存</span>
                    </div>
                    <div class="px-4 py-2 bg-green-100 text-green-800 rounded-full inline-flex items-center">
                        <i class="fas fa-bolt mr-2"></i>
                        <span>极高效率</span>
                    </div>
                    <div class="px-4 py-2 bg-purple-100 text-purple-800 rounded-full inline-flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>实用防护</span>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-10 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                <p class="text-gray-400">
                    <a href="http://www.yuque.com/jtostring" class="hover:text-white transition-colors">www.yuque.com/jtostring</a>
                </p>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            flowchart: {
                useMaxWidth: false
            }
        });
    </script>
</body>
</html>